﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RichList
{
    class Util
    {

        internal static string FormatSize(long len)
        {
            
            int i = 0;
            long left = 0;
            string[] S = { "B", "KB", "MB", "GB", "TB", "XX" };

            for (i = 0; i < S.Length; ++i)
            {
                if (len / 1024 == 0)
                {
                    break;
                }
                left = len % 1024;
                len /= 1024;
            }
            return string.Format("{0:F2}",len+(double)left/1024) + S[i];
        }
    }
}
